package com.cykj.controller;

import com.cykj.service.impl.UserServiceImpl;
import com.cykj.util.ResponseDto;
import com.cykj.vo.CourseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
    @RequestMapping("/user")
public class UserController {
    @Autowired
    private UserServiceImpl userService;

    @RequestMapping("/login")
    @ResponseBody
    public ResponseDto login(@RequestParam("acc") String account,@RequestParam("pwd") String pwd){
        //System.out.println("acc=" +account);
        //System.out.println("pwd=" +pwd);
        //System.out.println("hello login");
        //ResponseDto dto = new ResponseDto(1,"成功",null);
        ResponseDto dto = userService.login(account, pwd);
        System.out.println(dto);

        return dto;
    }
    @RequestMapping("/reg")
    public String reg(){
        System.out.println("注册");
        return "../index.jsp";
    }

    @RequestMapping("/testSearch")
    @ResponseBody
    public String testSearch(@RequestBody CourseVo vo){
        System.out.println(vo);
        return "收到的";

    }

    @RequestMapping("/index")
    public String index(){
        return "/index.html";
    }

}
